//
//  File.swift
//  
//
//  Created by ZhipengZheng on 2020/6/2.
//

import Foundation
import JAZCommandParse

var encode: Int = 0
var demo: Int64 = 0
var path: String = ""

let parse = CommandParse(description: "\(CommandName)Demo 处理")

try! parse.addParameter("-e", value: &encode, description: """
    编码
    数据
""")
try! parse.addParameter("-s", value: &path, description: """
    文件路径
""")
try! parse.addParameter("-d", value: &demo, description: """
    Demo 字段
""")
try! parse.addParameter("-a", miniKey: "", valueType: Int.self, description: """
    测试异常Action
""", throwsAction: { (value) in
    throw CommandParseError.extend(name: "测试异常Action", detail: "测试异常Action \(value)")
})
try! parse.addParameter("-ba", description: """
    测试异常Action Ba
""", throwsAction: { (value: String) in
    throw CommandParseError.extend(name: "测试异常Action", detail: "测试异常Action \(value)")
})
try! parse.addParameter("-bool", description: """
    测试Bool值解析 Bool值只可以为 true， false 传入 0，1 不能成功解析
""", throwsAction: { (value: Bool) in
    print(value)
})
parse.addDefaultHelpParameter()
do {
    try parse.parse()
    print("encode \(encode), path \(path), demo \(demo)")
} catch {
    print(error)
}
